float4x4 View;
float4x4 Projection;

float3 lightdir1 = {-0.5265408, -0.5735765, -0.6275069};
float3 lightdir2 = {0.7198464, 0.3420201, 0.6040227};
float3 lightdir3 = {0.4545195, -0.7660444, 0.4545195};
float4 lightColor = {0.8,0.8,0.8,1.0};

texture Texture;
sampler Sampler = sampler_state
{
    Texture = (Texture);
    
    MinFilter = Linear;
    MagFilter = Linear;
    MipFilter = Linear;
    
    AddressU = Clamp;
    AddressV = Clamp;
};

// TODO: add effect parameters here.

struct VertexShaderInput
{
    float4 Position : POSITION0;
};

struct VertexShaderOutput
{
    float4 Position : POSITION0;
    float2 Texcoord : TEXCOORD0;
    float4 LightColor : TEXCOORD1;
};

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    VertexShaderOutput output;
    
    float4 pos = input.Position;
    pos.y = 0.1;
    pos.xz = (pos.xz*2.0 - 1.0)*50.0;
    pos.z *= -1.0;
    pos.w = 1.0;

    float4 viewPosition = mul(pos, View);
    output.Position = mul(viewPosition, Projection);
    output.Texcoord = input.Position.xz;
    output.LightColor = float4(0,0,0,0);
    
    float NdotL = saturate(dot(float3(0,1,0),-lightdir1));
    output.LightColor = lightColor*NdotL;
    output.LightColor.a = 1.0;

    return output;
}

float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
	float4 shadow = tex2D(Sampler,input.Texcoord).a;
	float4 c = input.LightColor;
	return shadow;
}

technique Technique1
{
    pass Pass1
    {
        // TODO: set renderstates here.

        VertexShader = compile vs_2_0 VertexShaderFunction();
        PixelShader = compile ps_2_0 PixelShaderFunction();
    }
}
